package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.CancleIndentBean;
import com.lwj.liwanjia.impl.CancleIndentView;
import com.lwj.liwanjia.model.CancleIndentModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/20.
 */

public class CancleIndentPresenter {
    private CancleIndentView cancleIndentView;
    private CancleIndentModel cancleIndentModel;

    public CancleIndentPresenter(CancleIndentView cancleIndentView) {
        this.cancleIndentView = cancleIndentView;
        cancleIndentModel = new CancleIndentModel();
    }

    public void CancleIndent(String token, String tradeId) {
        if (cancleIndentView != null) {
            cancleIndentModel.cacleIndent(token, tradeId, new Subscriber<CancleIndentBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    cancleIndentView.showError((Exception) e);
                }

                @Override
                public void onNext(CancleIndentBean cancleIndentBean) {
                    cancleIndentView.cancleIndent(cancleIndentBean);
                }
            });
        }
    }
}
